package com.ruoyi.web.controller.qiushi.equipment;

import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.qiushi.domain.equipment.QiushiDeviceBindRecord;
import com.ruoyi.qiushi.service.equipment.IQiushiDeviceBindRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 设备列Controller
 *
 * @author ruoyi
 * @date 2024-02-28
 */
@RestController
@RequestMapping("/qiushi/equipment/qiushidevicebindrecord")
public class QiushiDeviceBindRecordController extends BaseController {
    @Autowired
    private IQiushiDeviceBindRecordService qiushiDeviceBindRecordService;

    /**
     * 查询设备列列表
     */
    @PreAuthorize("@ss.hasPermi('qiushi:equipment:qiushidevicebindrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(QiushiDeviceBindRecord qiushiDeviceBindRecord) {
        startPage();
        List<QiushiDeviceBindRecord> list = qiushiDeviceBindRecordService.selectQiushiDeviceBindRecordList(qiushiDeviceBindRecord);
        return getDataTable(list);
    }

    /**
     * 导出设备列列表
     */
    @PreAuthorize("@ss.hasPermi('qiushi:equipment:qiushidevicebindrecord:export')")
    @Log(title = "设备列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QiushiDeviceBindRecord qiushiDeviceBindRecord) {
        List<QiushiDeviceBindRecord> list = qiushiDeviceBindRecordService.selectQiushiDeviceBindRecordList(qiushiDeviceBindRecord);
        ExcelUtil<QiushiDeviceBindRecord> util = new ExcelUtil<QiushiDeviceBindRecord>(QiushiDeviceBindRecord.class);
        util.exportExcel(response, list, "设备列数据");
    }

    /**
     * 获取设备列详细信息
     */
    @PreAuthorize("@ss.hasPermi('qiushi:equipment:qiushidevicebindrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(qiushiDeviceBindRecordService.selectQiushiDeviceBindRecordById(id));
    }

    /**
     * 新增设备列
     */
    @PreAuthorize("@ss.hasPermi('qiushi:equipment:qiushidevicebindrecord:add')")
    @Log(title = "设备列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QiushiDeviceBindRecord qiushiDeviceBindRecord) {
        return toAjax(qiushiDeviceBindRecordService.insertQiushiDeviceBindRecord(qiushiDeviceBindRecord));
    }

    /**
     * 修改设备列
     */
    @PreAuthorize("@ss.hasPermi('qiushi:equipment:qiushidevicebindrecord:edit')")
    @Log(title = "设备列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QiushiDeviceBindRecord qiushiDeviceBindRecord) {
        return toAjax(qiushiDeviceBindRecordService.updateQiushiDeviceBindRecord(qiushiDeviceBindRecord));
    }

    /**
     * 删除设备列
     */
    @PreAuthorize("@ss.hasPermi('qiushi:equipment:qiushidevicebindrecord:remove')")
    @Log(title = "设备列", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(qiushiDeviceBindRecordService.deleteQiushiDeviceBindRecordByIds(ids));
    }
}
